package com.chinaunicom.behavior.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2022/8/16 15:46
 * Description:
 */
public class BookShelf implements Aggregate{
    private List<Book> bookList;
    
    public BookShelf(){
        this.bookList = new ArrayList<>();
    }
    
    
    @Override
    public Iterator iterator() {
        return new BookShelfIterator(this);
    }
    
    
    public Book getBookAt(int index){
        return this.bookList.get(index);
    }
    
    public void appendBook(Book book){
        bookList.add(book);
    }
    
    public int getLength(){
        return this.bookList.size();
    }
    
    
    
}
